package hp.com.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class LanJieQi implements HandlerInterceptor{

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		//获取官网地址
		String uri = request.getRequestURI();
		if(uri.indexOf("manager.do")>0 || uri.indexOf("userdeng.do")>0){
			return true;
		}
		HttpSession session = request.getSession();
		String musername = (String) session.getAttribute("musername");
		String unamename = (String) session.getAttribute("unamename");
		if(musername!=null || unamename!=null){
			return true;
		}
		request.getRequestDispatcher("login.jsp").forward(request, response);
		session.setAttribute("msg","请正确登陆！");
		return false;
	}

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		
	}

	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		
	}

}

